home *** CD-ROM | disk | FTP | other *** search
-
- {$A+} { Align data }
- {$B-} { Boolean evaluation }
- {$E+} { 80x87 emulator }
- {$F-} { Force FAR calls }
- {$G+} { 80286 code }
- {$I-} { I/O checking }
- {$K-} { Smart Callbacks }
- {$N-} { 80x87 code }
- {$O-} { Overlays allowed }
- {$P-} { Open parameters }
- {$T-} { Typed pointers }
- {$V-} { String VAR checking }
- {$W-} { Windows stack frame for real mode }
- {$X+} { Extended syntax }
-
- {$IFDEF DEBUG}
- {$D+} { Debug information }
- {$L+} { Local symbols }
- {$Q+} { Overflow checking }
- {$R+} { Range checking }
- {$S+} { Stack checking }
- {$Y+} { Symbol reference information }
- {$ELSE}
- {$D-} { Debug information }
- {$L-} { Local symbols }
- {$Q-} { Overflow checking }
- {$R-} { Range checking }
- {$S-} { Stack checking }
- {$Y-} { Symbol reference information }
- {$ENDIF}
-
- {$C Moveable Demandload Discardable} { Code Segment attributes }
-
- UNIT FrameDlg;
-
- {
- Copyright (c) 1992 by Olaf He▀ (Hess), Munich, Germany.
-
- Please feel free to use this code in your own programs.
- If you make $$$ with it ->> You have my ID!
- If you find any bugs or do any changes to the source code that you find
- generally useful please send me a message to my CompuServe account
- 100 031, 35 36.
-
- Thanks.
- }
-
- {$R FRAMEDLG.RES}
-
- INTERFACE
-
- USES WinProcs, WinTypes, OWindows, ODialogs;
-
- CONST
- rgbLightGray = $C0C0C0; { Light gray }
-
- TYPE
- PFrameStatic = ^TFrameStatic;
- TFrameStatic = OBJECT (TStatic)
- PRIVATE
- PROCEDURE WMPaint (VAR Msg: TMessage); VIRTUAL wm_First + wm_Paint;
- PROCEDURE PaintFrame; VIRTUAL;
- END; { TFrameStatic }
-
-
- PStaticUp = ^TStaticUp;
- TStaticUp = OBJECT (TFrameStatic)
- PROCEDURE SetupWindow; VIRTUAL;
- PROCEDURE PaintFrame; VIRTUAL;
- END; { TStaticUp }
-
-
- PStaticDown = ^TStaticDown;
- TStaticDown = OBJECT (TFrameStatic)
- PROCEDURE SetupWindow; VIRTUAL;
- PROCEDURE PaintFrame; VIRTUAL;
- END; { TStaticDown }
-
- PFrameDown = ^TFrameDown;
- TFrameDown = OBJECT (TStaticDown)
- CONSTRUCTOR InitResource (AParent: PWindowsObject;
- ResourceId: Integer);
- PROCEDURE SetupWindow; VIRTUAL;
- END; { TFrameDown }
-
- PFrameUp = ^TFrameUp;
- TFrameUp = OBJECT (TStaticUp)
- CONSTRUCTOR InitResource (AParent: PWindowsObject;
- ResourceId: Integer);
- PROCEDURE SetupWindow; VIRTUAL;
- END; { TFrameUp }
-
- PSteelDlgWnd = ^TSteelDlgWnd;
- TSteelDlgWnd = OBJECT (TDlgWindow)
- PROCEDURE WMCtlColor (VAR Msg: TMessage);
- VIRTUAL wm_First + wm_CtlColor;
- END; { TSteelDlgWnd }
-
- PSteelDialog = ^TSteelDialog;
- TSteelDialog = OBJECT (TDialog)
- PROCEDURE WMCtlColor (VAR Msg: TMessage);
- VIRTUAL wm_First + wm_CtlColor;
- END; { TSteelDialog }
-
-
- VAR
- hBackgroundBrush : hBrush; { Background brush }
- fDoColors : Boolean; { TRUE if graphics card support more than 8 colors }
-
- IMPLEMENTATION
-
- VAR
- OldExitProc : Pointer;
-
- (* ---- *)
-
- PROCEDURE TFrameStatic.WMPaint (VAR Msg: TMessage);
- { Paint the static control }
-
- BEGIN
- INHERITED WMPaint (Msg); { Call ancestor }
- PaintFrame; { Paint borders }
- END; { TFrameStatic.WMPaint }
-
- (* ---- *)
-
- PROCEDURE TFrameStatic.PaintFrame;
- { Just a placeholder }
-
- BEGIN
- END; { TFrameStatic.PaintFrame }
-
- (* ---- *)
-
- PROCEDURE TStaticUp.SetupWindow;
- { Set the window style attributes }
-
- VAR
- lStyle : LongInt;
-
- BEGIN
- INHERITED SetupWindow; { Call ancestor }
-
- { Get and set the style bits }
- lStyle := GetWindowLong (hWindow, gwl_Style);
- lStyle := lStyle AND NOT ws_Border;
- SetWindowLong (hWindow, gwl_Style, lStyle);
- END; { TStaticUp.SetupWindow }
-
- (* ---- *)
-
- PROCEDURE TStaticUp.PaintFrame;
- { Paint a raised border }
-
- VAR
- hWindowDC : hDC;
- hOldBrush : hBrush;
- rc : TRect;
- x, y : Integer;
-
- BEGIN
- GetClientRect (hWindow, rc); { Get size }
- { Coordinates of the lower right corner }
- x := rc.Right;
- y := rc.Bottom;
- hWindowDC := GetDC (hWindow);
-
- IF (NOT fDoColors) THEN
- BEGIN { Not enough colors ->> paint in black }
- hOldBrush := SelectObject (hWindowDC, GetStockObject (BLACK_BRUSH));
- PatBlt (hWindowDC, 0, 0, x, 1, PATCOPY); { Top line }
- PatBlt (hWindowDC, 0, 0, 1, y, PATCOPY); { Left line }
- PatBlt (hWindowDC, 1, y - 1, x - 1, 1, PATCOPY); { Bottom line }
- PatBlt (hWindowDC, x - 1, 1, 1, y - 1, PATCOPY); { Right line }
- END { if }
- ELSE
- BEGIN
- { Color of the top and left line is white }
- hOldBrush := SelectObject (hWindowDC,
- GetStockObject (WHITE_BRUSH));
-
- PatBlt (hWindowDC, -1, -1, x + 2, 2, PATCOPY); { Paint top line }
- PatBlt (hWindowDC, -1, 1, 2, y, PATCOPY); { Paint left line }
-
- { Color of the bottom and right line is gray }
- SelectObject (hWindowDC, GetStockObject (GRAY_BRUSH));
-
- { Paint bottom line }
- PatBlt (hWindowDC, 1, y - 1, x, 1, PATCOPY); { Inside }
- PatBlt (hWindowDC, 0, y, x + 1, 1, PATCOPY); { Middle }
- PatBlt (hWindowDC, -1, y + 1, x + 2, 1, PATCOPY); { Outside }
-
- { Paint right line }
- PatBlt (hWindowDC, x - 2, 1, 1, y - 2, PATCOPY); { Inside }
- PatBlt (hWindowDC, x - 1, 0, 1, y - 1, PATCOPY); { Middle }
- PatBlt (hWindowDC, x, -1, 1, y, PATCOPY); { Outside }
- END; { else }
-
- SelectObject (hWindowDC, hOldBrush);
- ReleaseDC (hWindow, hWindowDC);
- END; { TStaticUp.PaintFrame }
-
- (* ---- *)
-
- PROCEDURE TStaticDown.SetupWindow;
- { Set the window style attributes }
-
- VAR
- lStyle : LongInt;
-
- BEGIN
- INHERITED SetupWindow; { Call ancestor }
-
- { Get and set the style bits }
- lStyle := GetWindowLong (hWindow, gwl_Style);
- lStyle := lStyle AND NOT ws_Border;
- SetWindowLong (hWindow, gwl_Style, lStyle);
- END; { TStaticDown.SetupWindow }
-
- (* ---- *)
-
- PROCEDURE TStaticDown.PaintFrame;
- { Paint a recessed static control }
-
- VAR
- hWindowDC : hDC;
- hOldBrush : hBrush;
- rc : TRect;
- x, y : Integer;
-
- BEGIN
- GetClientRect (hWindow, rc); { Get size }
- { Coordinates of the lower right corner }
- x := rc.Right;
- y := rc.Bottom;
- hWindowDC := GetDC (hWindow);
-
- IF (NOT fDoColors) THEN
- BEGIN { Not enough colors ->> paint in black }
- hOldBrush := SelectObject (hWindowDC, GetStockObject (BLACK_BRUSH));
- PatBlt (hWindowDC, 0, 0, x, 1, PATCOPY); { Top line }
- PatBlt (hWindowDC, 0, 0, 1, y, PATCOPY); { Left line }
- PatBlt (hWindowDC, 1, y - 1, x - 1, 1, PATCOPY); { Bottom line }
- PatBlt (hWindowDC, x - 1, 1, 1, y - 1, PATCOPY); { Right line }
- END { if }
- ELSE
- BEGIN
- { Color of the top and left line is gray }
- hOldBrush := SelectObject (hWindowDC,
- GetStockObject (GRAY_BRUSH));
-
- PatBlt (hWindowDC, -1, -1, x + 1, 3, PATCOPY); { Paint top line }
- PatBlt (hWindowDC, -1, 0, 3, y, PATCOPY); { Paint left line }
-
- { Color of the bottom and right line is white }
- SelectObject (hWindowDC, GetStockObject (WHITE_BRUSH));
-
- { Paint bottom line }
- PatBlt (hWindowDC, 1, y - 1, x - 1, 1, PATCOPY); { Inside }
- PatBlt (hWindowDC, 0, y, x - 1, 1, PATCOPY); { Outside }
-
- { Paint right line }
- PatBlt (hWindowDC, x - 1, 1, 1, y, PATCOPY); { Inside }
- PatBlt (hWindowDC, x, 0, 1, y + 1, PATCOPY); { Outside }
- END; { else }
-
- SelectObject (hWindowDC, hOldBrush);
- ReleaseDC (hWindow, hWindowDC);
- END; { TStaticDown.PaintFrame }
-
- (* ---- *)
-
- CONSTRUCTOR TFrameDown.InitResource (AParent: PWindowsObject;
- ResourceId: Integer);
-
- BEGIN
- { Call ancestor, set text length to 0 }
- INHERITED InitResource (AParent, ResourceId, 0);
- END; { TFrameDown.InitResource }
-
- (* ---- *)
-
- PROCEDURE TFrameDown.SetupWindow;
- { Set the window style attributes }
-
- VAR
- lStyle : LongInt;
-
- BEGIN
- TFrameStatic.SetupWindow; { Call TFrameStatic directly }
-
- { Set the style bits }
- lStyle := ws_Visible OR ws_Child OR ws_Group OR ss_WhiteRect;
- SetWindowLong (hWindow, gwl_Style, lStyle);
- END; { TFrameDown.SetupWindow }
-
- (* ---- *)
-
- CONSTRUCTOR TFrameUp.InitResource (AParent: PWindowsObject;
- ResourceId: Integer);
-
- BEGIN
- { Call ancestor, set text length to 0 }
- INHERITED InitResource (AParent, ResourceId, 0);
- END; { TFrameUp.InitResource }
-
- (* ---- *)
-
- PROCEDURE TFrameUp.SetupWindow;
- { Set the window style attributes }
-
- VAR
- lStyle : LongInt;
-
- BEGIN
- TFrameStatic.SetupWindow; { Call TFrameStatic directly }
-
- { Set the style bits }
- lStyle := ws_Visible OR ws_Child OR ws_Group OR ss_WhiteRect;
- SetWindowLong (hWindow, gwl_Style, lStyle);
- END; { TFrameUp.SetupWindow }
-
- (* ---- *)
-
- PROCEDURE TSteelDlgWnd.WMCtlColor (VAR Msg: TMessage);
- { Set the background color for the dialog window + it's controls }
-
- BEGIN
- DefWndProc (Msg); { Call standard proc first }
- WITH Msg DO
- IF (NOT fDoColors) THEN Exit { Not enough colors }
- ELSE
- BEGIN
- SetBkColor (wParam, rgbLightGray); { Set backround color }
-
- IF (lParamHi = CtlColor_Dlg) THEN
- { Background brush for dialog window }
- Result := hBackgroundBrush
- ELSE Result := GetStockObject (LtGray_Brush); { Gray in gray }
- END; { else }
- END; { TSteelDlgWnd.WMCtlColor }
-
- (* ---- *)
-
- PROCEDURE TSteelDialog.WMCtlColor (VAR Msg: TMessage);
- { Set the background color for the dialog window + it's controls }
-
- BEGIN
- WITH Msg DO
- IF (NOT fDoColors) THEN Exit { Not enough colors }
- ELSE
- BEGIN
- SetBkColor (wParam, rgbLightGray); { Set background color }
-
- IF (lParamHi = CtlColor_Dlg) THEN
- { Background brush for dialog window }
- Result := hBackgroundBrush
- ELSE Result := GetStockObject (LtGray_Brush); { Gray in gray }
- END; { else }
- END; { TSteelDialog.WMCtlColor }
-
- (* ---- *)
-
- PROCEDURE NewExitProc; FAR;
- { Release background brush }
-
- BEGIN
- DeleteObject (hBackGroundBrush); { Delete brush }
-
- { Call old EXIT-proc }
- ExitProc := OldExitProc;
- END; { NewExitProc }
-
- (* ---- *)
-
- VAR
- hBackgroundBitmap : hBitmap;
- hWindowsDC : hDC;
-
- BEGIN { FrameDlg }
- { Set new EXIT-proc }
- OldExitProc := ExitProc;
- ExitProc := @NewExitProc;
-
- { Can the graphics card display more than 8 colors }
- hWindowsDC := GetDC (0);
- fDoColors := GetDeviceCaps (hWindowsDC, NumColors) >= 8; { Get colors }
- ReleaseDC (0, hWindowsDC);
-
- { Load new background brush }
- hBackGroundBitmap := LoadBitmap (hInstance, 'MY_BRUSH');
- hBackGroundBrush := CreatePatternBrush (hBackGroundBitmap);
- DeleteObject (hBackGroundBitmap);
- END. { FrameDlg }
-